﻿using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;
using TabbedTemplate.Models;

namespace TabbedTemplate.Services
{
    public interface IBeijingCacheService
    {
        /// <summary>
        /// 是否已经初始化。判断版本
        /// </summary>
        bool BeijingInitialized();

        /// <summary>
        /// 初始化，copy新版本数据库
        /// </summary>
        Task InitializeBeijingAsync();
        /// <summary>
        /// 获取一家店铺。
        /// </summary>
        /// <param name="uid"></param>
        /// <returns></returns>
        Task<Store> GetBeijingStoreAsync(string uid);

        /// <summary>
        /// 获取满足给定条件的店铺集合。
        /// </summary>
        /// <param name="where">Where条件。</param>
        /// <param name="skip">跳过数量。</param>
        /// <param name="take">获取数量。</param>
        /// Expression 表达式 函数，参数，返回值
        /// Where 万能查找
        Task<IList<Store>> GetBeijingStoresAsync(Expression<Func<Store, bool>> where,
            int skip, int take);

        Task<IList<Store>> GetBeijingStoreByTagAsync(string Tag, int skip,
            int take);

        /// <summary>
        /// 关闭数据库。
        /// </summary>
        Task CloseAsync();
    }
    public static class BeijingCacheConstants
    {
        /**
         * nameof 关键字，把类型变成字符串
         * 如果后面把类名改变了，也能改变VersionKey的名称，编译时进行，不在运行时进行
         */
        ///<summary>
        /// 版本键
        /// </summary>
        public const String VersionKey = nameof(BeijingCacheConstants) + "." + nameof(Version);

        ///<summary>
        /// 版本号
        /// </summary>
        public const int Version = 1;

    }
}
